home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / midi / gfft.lha / gfft-2.03 / source / gfft-2.03-source.lha / complex.h < prev    next >
C/C++ Source or Header  |  1996-01-02  |  2KB  |  71 lines

  1. /***************************************************************************
  2.  *          Copyright (C) 1994  Charles P. Peterson                  *
  3.  *         4007 Enchanted Sun, San Antonio, Texas 78244-1254             *
  4.  *              Email: Charles_P_Peterson@fcircus.sat.tx.us                *
  5.  *                                                                         *
  6.  *          This is free software with NO WARRANTY.                  *
  7.  *          See gfft.c, or run program itself, for details.              *
  8.  *              Support is available for a fee.                      *
  9.  ***************************************************************************
  10.  *
  11.  * Program:     gfft--General FFT analysis
  12.  * File:        complex.h
  13.  * Purpose:     define structs and ops for complex numbers
  14.  * Author:      Charles Peterson (CPP)
  15.  * History:     29-June-1993 CPP; Created.
  16.  * Comment:     (1) C_MULT DOES NOT ALLOW INPUT & OUTPUT TO COINCIDE
  17.  *              (2) MACROS DO NOT ASSUME float or double data size
  18.  */
  19.  
  20. typedef struct {
  21. float real;
  22. float imaginary;
  23. } Complex_float;
  24.  
  25. typedef struct {
  26. double real;
  27. double imaginary;
  28. } Complex_double;
  29.  
  30.  
  31. #ifndef NO_STRUCT_ASSIGN
  32. #define CF_SWAP(a,b) {Complex_float tempc=(a); (a)=(b); (b)=tempc;}
  33. #else
  34. #define CF_SWAP(a,b) {\
  35.                 float tempf;\
  36.                 tempf = (a).real; \
  37.                 (a).real = (b).real; \
  38.                 (b).real = tempf; \
  39.                 tempf = (a).imaginary; \
  40.                 (a).imaginary = (b).imaginary; \
  41.                 (b).imaginary = tempf; \
  42.                    }
  43. #endif
  44.  
  45.  
  46. #define C_ADD(ADDEND, ADDENDUM, SUM) \
  47. { \
  48.     (SUM).real = (ADDEND).real + (ADDENDUM).real; \
  49.     (SUM).imaginary = (ADDEND).imaginary + (ADDENDUM).imaginary; \
  50. }
  51.  
  52. #define C_SUB(MINUEND, SUBTRAHEND, DIFFERENCE) \
  53. { \
  54.     (DIFFERENCE).real = (MINUEND).real - (SUBTRAHEND).real; \
  55.     (DIFFERENCE).imaginary = (MINUEND).imaginary - (SUBTRAHEND).imaginary; \
  56. }
  57.  
  58. #define C_MULT(MULTIPLICAND, MULTIPLIER, PRODUCT) \
  59. { \
  60.     (PRODUCT).real = (MULTIPLICAND).real * (MULTIPLIER).real - \
  61.       (MULTIPLICAND).imaginary * (MULTIPLIER).imaginary; \
  62.     (PRODUCT).imaginary = (MULTIPLICAND).real * (MULTIPLIER).imaginary + \
  63.       (MULTIPLICAND).imaginary * (MULTIPLIER).real; \
  64. }
  65.  
  66. /*
  67.  * And now, those prototypes involving complex numbers
  68.  */
  69. void cfft (Complex_float *datac, long n, int isign);
  70. void rfft (Complex_float *datac, long n, int isign); /* input float array */
  71.